<%--
  Created by IntelliJ IDEA.
  User: baiyu
  Date: 2021/11/21
  Time: 7:09 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户管理</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
</head>
<script type="text/javascript">
    $(function () {
        $('#login').click(function () {
            console.log("进入了");
            $.ajax({
                    type: 'post',
                    url: '${pageContext.request.contextPath}/user/login',
                    dataType: 'json',
                    data: {
                        "userName": document.getElementById('userName').value,
                        "password": document.getElementById('password').value
                    },
                    success: function (data) {
                        console.log(data);
                        if (data.success) {
                            alert("登陆成功");
                        } else {
                            alert(data.information);
                        }
                    },
                    error: function () {
                        alert("报错了")
                    }
                }
            )
        })
    })
</script>
<body>

<div>
    <p>账号：<input id="userName">登陆状态：
        <span id="LoginInfo">123</span>
    </p>
    <p>密码：<input id="password">
        <button id="login" type="submit">登陆</button>
    </p>
</div>

</body>
</html>
